package com.example.transactionhintassistant.controller;


import com.example.transactionhintassistant.pojo.dto.task.AddTaskDto;
import com.example.transactionhintassistant.pojo.dto.task.ChangeStatusDto;
import com.example.transactionhintassistant.pojo.dto.task.EditReminderLevel;
import com.example.transactionhintassistant.pojo.dto.task.EditTaskDto;
import com.example.transactionhintassistant.service.TasksService;
import com.example.transactionhintassistant.utils.result.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/task")
@Tag(name="5.今日事务模块")
public class TaskController {

    @Autowired
    private TasksService tasksService;

    @GetMapping("/getTodayTaskNow")
    @Operation(summary = "获取今日此时刻的信息", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> getTOdayTaskNow(){
        return tasksService.getTodayTaskNow();
    }

    @GetMapping("/getTodayTask")
    @Operation(summary = "获取今日所有事务信息", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> getTodayTask(){
        return tasksService.getTodayTask();
    }

    @GetMapping("/getAllTask/{completionStatus}")
    @Operation(summary = "获取指定状态所有事务信息", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> getAllask(@PathVariable("completionStatus") @RequestParam(required = false) Integer completionStatus){
        return tasksService.getAllTask(completionStatus);
    }


    @PostMapping("/addTodayTask")
    @Operation(summary = "添加今日事务信息", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> addTodayTask(@RequestBody  AddTaskDto addTaskDto){
        return tasksService.addTodayTask(addTaskDto);
    }

    @PutMapping("/editTodayTask")
    @Operation(summary = "修改今日事务信息", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> editTodayTask(@RequestBody @Validated EditTaskDto editTaskDto){
        return tasksService.editTodayTask(editTaskDto);
    }

    @PutMapping("/editReminderLevel")
    @Operation(summary = "修改提醒级别", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> editReminderLevel(@RequestBody @Validated EditReminderLevel editReminderLevel){
        return tasksService.editReminderLevel(editReminderLevel);
    }

    @DeleteMapping("/deleteTask/{id}")
    @Operation(summary = "删除今日事务", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> deleteTask(@PathVariable("id") Integer id){
        return tasksService.deleteTask(id);
    }

    @Operation(summary = "获取本周全部事务",security = {@SecurityRequirement(name = "Authorization")})
    @GetMapping("/getWeekAllInfo")
    public Result<Object> getWeekAllInfo(@RequestParam(required = false) Integer status){
        return tasksService.getWeekAllInfo(status);
    }

    @GetMapping("/today-progress")
    @Operation(summary = "获取今日事务进度", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> getTodayProgress() {
        return tasksService.getTodayProgress();
    }

    @PutMapping("/changeStatus")
    @Operation(summary = "修改完成状态", security = {@SecurityRequirement(name = "Authorization")})
    public Result<Object> changeStatus(@RequestBody ChangeStatusDto changeStatusDto){
        return tasksService.changeStatus(changeStatusDto);
    }


}
